/*按钮背景样式*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:frametrim/utility/screen.dart';

//点击事件回调
class ButtonView extends StatelessWidget {
  //文字
  late String textStr;
  late Color? textColor;
  late double? fontSize;
  late FontWeight mfontWeight;

  //按钮
  late Color borderColor;
  late Color fillColor;
  late double borderRadius;
  late double? buttonHeight;
  late double? buttonWidth;
  late double? marginHorizon;

  //事件
  late VoidCallback onPress;

  ButtonView({required this.textStr,
    this.textColor = const Color(0XFF000000),
    required this.borderColor,
    this.buttonHeight = 45,
    this.fontSize = 16,
    this.buttonWidth,
    this.mfontWeight = FontWeight.bold,
    this.marginHorizon = 28,
    this.fillColor = const Color(0xFFffffff),
    required this.borderRadius,
    required this.onPress});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onPress,
      child: Container(
        alignment: Alignment.center,
        height: buttonHeight,
        width: buttonWidth ?? Screen.width,
        margin: EdgeInsets.fromLTRB(marginHorizon!, 0, marginHorizon!, 0),
        decoration: BoxDecoration(
            border: Border.all(color: borderColor, width: 1),
            color: fillColor,
            borderRadius: BorderRadius.all(Radius.circular(borderRadius))
        ),
        child: Text(textStr,
          style: TextStyle(fontSize: fontSize, color: textColor, fontWeight:mfontWeight),),
      ),
    );
  }
}
